package com.htc.adapter;

import java.util.ArrayList;
import java.util.zip.Inflater;

import com.htc.dlc.R;
import com.htc.dlc.SettingsActivity;
import com.htc.model.dto.FitnessGroupDTO;
import com.htc.utils.CommonActions;
import com.htc.utils.CommonObjects;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class SpinnerAdapter1 extends ArrayAdapter<FitnessGroupDTO> {
	CommonActions ca;
	Context mContext;
	private LayoutInflater mInflater;
	ArrayList<FitnessGroupDTO> mList;
	public String selectedString;
	SettingsActivity st = new SettingsActivity();

	public SpinnerAdapter1(Context paramContext, int paramInt,
			ArrayList<FitnessGroupDTO> paramArrayList) {
		super(paramContext, paramInt, paramArrayList);
		this.mList = paramArrayList;
		this.mContext = paramContext;
		this.mInflater = LayoutInflater.from(paramContext);
		this.ca = new CommonActions(paramContext);
	}

	public int getCount() {
		if (this.mList != null)
			return this.mList.size();
		return 0;
	}

	public View getDropDownView(int position, View convertView,
			ViewGroup paramViewGroup) {

		if (convertView == null) {
			convertView = mInflater.inflate(
					R.layout.wellness_overview_spinner_row, paramViewGroup,
					false);
		}
		ViewHolder localViewHolder = new ViewHolder();
		localViewHolder.txt_spinner = ((TextView) convertView
				.findViewById(R.id.txt_wellness_spinner));
		if(st.flag == 0){
			localViewHolder.txt_spinner.setText(((FitnessGroupDTO) this.mList
					.get(position)).getFitnessGroupName());
		}else if(st.flag == 1){
			localViewHolder.txt_spinner.setText(((FitnessGroupDTO) this.mList
					.get(position)).getFitnessGroupNameAr());
		}
		
		return convertView;
	}

	public long getItemId(int paramInt) {
		return paramInt;
	}

	public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) {

		View rootView = null;
		if (paramView == null) {
			rootView = mInflater.inflate(
					R.layout.wellness_overview_spinner_row, paramViewGroup,
					false);
		}
		ViewHolder localViewHolder = new ViewHolder();
		localViewHolder.txt_spinner = ((TextView) rootView
				.findViewById(R.id.txt_wellness_spinner));
		
		
		if(st.flag == 0){
			localViewHolder.txt_spinner.setText(((FitnessGroupDTO) this.mList
					.get(paramInt)).getFitnessGroupName());
		}else if(st.flag == 1){
			localViewHolder.txt_spinner.setText(((FitnessGroupDTO) this.mList
					.get(paramInt)).getFitnessGroupNameAr());
		}
		return rootView;
	}

	class ViewHolder {
		public TextView txt_spinner;
	}
}
